home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / mimelib / address.h next >
Encoding:
C/C++ Source or Header  |  2007-05-14  |  5.6 KB  |  156 lines

  1. //=============================================================================
  2. // File:       address.h
  3. // Contents:   Declarations for DwAddress
  4. // Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
  5. // WWW:        http://www.fwb.gulf.net/~dwsauder/mimepp.html
  6. //
  7. // Copyright (c) 1996, 1997 Douglas W. Sauder
  8. // All rights reserved.
  9. //
  10. // IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
  11. // INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
  12. // THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
  13. // HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. //
  15. // DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
  16. // NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  17. // PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
  18. // BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
  19. // SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. //
  21. //=============================================================================
  22.  
  23. #ifndef DW_ADDRESS_H
  24. #define DW_ADDRESS_H
  25.  
  26. #ifndef DW_CONFIG_H
  27. #include <mimelib/config.h>
  28. #endif
  29.  
  30. #ifndef DW_FIELDBDY_H
  31. #include <mimelib/fieldbdy.h>
  32. #endif
  33.  
  34. #ifndef DW_TOKEN_H
  35. #include <mimelib/token.h>
  36. #endif
  37.  
  38. class DwAddressList;
  39. class DwMailboxList;
  40.  
  41. //=============================================================================
  42. //+ Name DwAddress -- Abstract class representing an RFC-822 address
  43. //+ Description
  44. //. {\tt DwAddress} represents an {\it address} as described in RFC-822.
  45. //. You may not instantiate objects of type {\tt DwAddress}, since
  46. //. {\tt DwAddress} is an abstract base class.  Instead, you must instantiate
  47. //. objects of type {\tt DwMailbox} or {\tt DwGroup}, which are subclasses
  48. //. of {\tt DwAddress}.
  49. //.
  50. //. To determine the actual type of a {\tt DwAddress} object, you can use
  51. //. the member functions {\tt IsMailbox()} and {\tt IsGroup()}.
  52. //.
  53. //. If the string representation assigned to a {\tt DwAddress} is improperly
  54. //. formed, the parse method will fail.  To determine if the parse method
  55. //. failed, call the member function {\tt IsValid()}.
  56. //.
  57. //. A {\tt DwAddress} object can be contained in list.  To get the next
  58. //. {\tt DwAddress} object in the list, call the member function {\tt Next()}.
  59. //=============================================================================
  60. // Last modified 1997-08-23
  61. //+ Noentry ~DwAddress mNext mIsValid sClassName _PrintDebugInfo
  62.  
  63.  
  64. class DW_EXPORT DwAddress : public DwFieldBody {
  65.  
  66.     friend class DwAddressList;
  67.  
  68. public:
  69.  
  70.     virtual ~DwAddress();
  71.  
  72.     DwBool IsMailbox() const;
  73.     //. Returns true value if this object is a {\tt DwMailbox}.
  74.  
  75.     DwBool IsGroup() const;
  76.     //. Returns true value if this object is a {\tt DwGroup}.
  77.  
  78.     inline DwBool IsValid() const;
  79.     //. Returns true value if the last parse was successful.
  80.     //. Returns false if the last parse failed (bad address) or
  81.     //. the {\tt Parse()} member function was never called.
  82.  
  83.     DwAddress* Next() const;
  84.     //. Returns the next {\tt DwAddress} object in the list when the object
  85.     //. is included in a list of addresses.  The function is used when
  86.     //. iterating a list.
  87.  
  88.     void SetNext(DwAddress* aAddress);
  89.     //. Sets the next {\tt DwAddress} object in the list.  This member function
  90.     //. generally should not be used, since {\tt DwAddressList} has member
  91.     //. functions to manage its list of {\tt DwAddress} objects.
  92.  
  93. protected:
  94.  
  95.     DwAddress();
  96.     DwAddress(const DwAddress& aAddr);
  97.     DwAddress(const DwString& aStr, DwMessageComponent* aParent=0);
  98.     //. The first constructor is the default constructor, which sets the
  99.     //. {\tt DwAddress} object's string representation to the empty string
  100.     //. and sets its parent to {\tt NULL}.
  101.     //.
  102.     //. The second constructor is the copy constructor, which copies the
  103.     //. string representation and all attributes from {\tt aAddress}.
  104.     //. The parent of the new {\tt DwAddress} object is set to {\tt NULL}.
  105.     //.
  106.     //. The third constructor copies {\tt aStr} to the {\tt DwAddress}
  107.     //. object's string representation and sets {\tt aParent} as its parent.
  108.     //. The virtual member function {\tt Parse()} should be called immediately
  109.     //. after this constructor in order to parse the string representation.
  110.     //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of
  111.     //. a class derived from {\tt DwField}.
  112.  
  113.     const DwAddress& operator = (const DwAddress& aAddr);
  114.     //. This is the assignment operator, which performs a deep copy of
  115.     //. {\tt aAddr}.  The parent node of the {\tt DwAddress} object
  116.     //. is not changed.
  117.  
  118.     int mIsValid;
  119.     //. This data member is set to true if the parse method was successful.
  120.  
  121. private:
  122.  
  123.     DwAddress* mNext;
  124.     static const char* const sClassName;
  125.  
  126. public:
  127.  
  128.     virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
  129.     //. This virtual function, inherited from {\tt DwMessageComponent},
  130.     //. prints debugging information about this object to {\tt aStrm}.
  131.     //. It will also call {\tt PrintDebugInfo()} for any of its child
  132.     //. components down to a level of {\tt aDepth}.
  133.     //.
  134.     //. This member function is available only in the debug version of
  135.     //. the library.
  136.  
  137.     virtual void CheckInvariants() const;
  138.     //. Aborts if one of the invariants of the object fails.  Use this
  139.     //. member function to track down bugs.
  140.     //.
  141.     //. This member function is available only in the debug version of
  142.     //. the library.
  143.  
  144. protected:
  145.  
  146.     void _PrintDebugInfo(std::ostream& aStrm) const;
  147.  
  148. };
  149.  
  150. inline DwBool DwAddress::IsValid() const
  151. {
  152.     return mIsValid;
  153. }
  154.  
  155. #endif
  156.